<template>
	<view class="container">
		<!--  #ifdef  APP-PLUS-->
		<uni-nav-bar fixed='true' @clickLeft='back' statusBar='true' style="width: 100%;">
		
			<view slot='left'>
				<text class="cuIcon-back"></text>
		
			</view>
			<view class="status-center padding-left center bg-F4F4F4  round" style="height: 70rpx;margin-left: -30px;">
				<image :src="baseUrl + '/static/search_for.png'" mode="" style="width: 25rpx;height: 25rpx;">
				</image>
				<input type="text" v-model="search" @input='search' value="" class="text-13 f-grow1 padding-left-sm"
					placeholder="请输入订单描述" />
			</view>
		
		</uni-nav-bar>
		<!--  #endif -->
		<!--  #ifdef     MP-WEIXIN -->
		<view class="bg-white">
			<kg-custom :isBack="true" bgColor="bg-white">
				<block slot="left">
					<view class="flex justify-start align-center bg-F4F4F4 padding-left round margin-left-sm"
						style="height: 70rpx;width: 460rpx;">
						<image :src="baseUrl + '/static/search_for.png'" mode="" style="width: 25rpx;height: 25rpx;">
						</image>
						<input @input='search' v-model='search' type="text" value="" class="text-13 f-grow1 padding-left-sm"
							placeholder="请输入订单描述" />
					</view>
				</block>
			</kg-custom>
		<!-- 	<view class="text-666 text-df flex justify-between align-center nav">
				<scroll-view scroll-x class="bg-white nav text-666" scroll-with-animation :scroll-left="scrollLeft">
					<view class="cu-item" :class="item.id==TabCur?'color cur text-bold':''"
						v-for="(item,index) in typeList" @tap="tabSelect" :data-id="item.id">
						<view>{{item.name}}</view>
					</view>
				</scroll-view>
			</view> -->
		</view>
			<!--  #endif -->
		<view   @click="toPage('/filePage/pages/orderServiceDetail/orderServiceDetail?id='+item.id+'&paidan=1')"       class="bg-white radius10 padding-sm margin-sm" v-for='(item,index) in list' :key='index'>
			<view class="flex justify-between align-center text-bold">
				<view class="text-15 text-333">
					{{item.description}}
				</view>
				<text style="font-weight: normal;">
					<block v-if='item.serviceStatus==0'>待付款</block>
					<block v-if='item.serviceStatus==1'>待接单</block>
					<block v-if='item.serviceStatus==2'>已接单</block>
					<block v-if='item.serviceStatus==3'>已完成</block>
					<block v-if='item.serviceStatus==4'>已验收</block>
					<block v-if='item.serviceStatus==5'>已评价</block>
					<block v-if='item.serviceStatus==6'>已取消</block>
				</text>
			</view>
			<view class="flex justify-between align-center">
				<view class="kind">{{item.sysCategoryName}}</view>
				<view style="color:red" class="kind" v-if='item.applyAuditStatus==0'>派单中</view>
				<view style="color:red" class="kind" v-if='item.applyAuditStatus==1'>已接单</view>
				<view style="color:red" class="kind" v-if='item.applyAuditStatus==2'>已拒绝</view>
			</view>

			<view class="flex justify-start margin-top align-center justify-between">
				<view class="flex align-center">
					<view class="price">￥<text>{{item.price/100}}</text></view>
					<view class="type-order">{{item.title}}</view>
				</view>

				<view>倒计时{{item.pastTime}}小时</view>
			</view>

			<view class="flex justify-end align-center margin-top"
				v-if='item.serviceStatus==1&& item.applyAuditStatus==0'>
				<button class="receive" @click="submit(1,item.applyAuditId)">接单</button>
                 <button style="margin-left: 40rpx;" class="receive" @click="submit(2,item.applyAuditId)">拒绝</button>
                 </view>
		</view>

		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from "@/common/util/BetterPull";
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = "loading";
					const param = {

						pageNum: page,
						pageSize: 10,
						receiverId: uni.getStorageSync('userId')
					}
				  if(this.word){
				  	obj['keywords'] = this.word
				  }
				  const [err, res] = await this.$get(this.$api.listOrderServicePoolApply, param);
					if (res) {
						var data = res.data.list;
						done(data);
						if (data.length < 10) {
							this.loading = "noMore";
						} else {
							this.loading = "more";
						}
					}
					if (err) {
						done([]);
						this.loading = "noMore";
					}
				},
			}),
		],
		data() {
			return {
				baseUrl: this.$config.baseUrl,
				loading: "more",
				scrollLeft: 0,
				TabCur: '',
				userName: '',
				userMobile: '',
				typeList: [{
						id: 0,
						name: '全部'
					}, {
						name: '待接单',
						id: '1'
					}, {
						name: '已接单',
						id: '2'
					}, {
						name: '已完成',
						id: '3'
					},
					{
						name: '已验收',
						id: '4'
					},
					{
						name: '已评价',
						id: '5'
					},
					{
						name: '已取消',
						id: '6'
					}
				]
			};
		},
		methods: {
			back() {
				console.log(1111)
				uni.navigateBack({
			
				})
			},
			toPage(url) {
				this.$util.openNewPage(url)
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				console.log(this.scrollLeft)
				this.Refresh()
			},
			search(){
			     this.Refresh()
				
			},
			submit(status,applyAuditId) {
				let title = ''
				const that = this
				if (status==1) {
					title = '你确定审核通过吗'
				} else {
					title = '你确定审核不通过'
				}
				uni.showModal({
				content: title,
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							const data = {
								auditStatus: status,
								id: applyAuditId,
								auditUserId: uni.getStorageSync('userId') || appConfig.userId
							}
							that.$jsonPost(that.$api.auditForShop, data).then(res => {
								const [err, rs] = res
								if (rs) {
									that.$util.msg(res.message)
									that.Refresh()
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav {
		.on {
			border-bottom: 6rpx solid #ED7200;
			font-weight: bold;
			color: #221815;
		}

		view {
			border-bottom: 6rpx solid #fff;
		}
	}

	.btn2 {
		padding: 20rpx 24rpx;
		border: 2rpx solid;
	}

	.footer {
		position: fixed;
		left: 20rpx;
		right: 20rpx;
		bottom: 98rpx;

		image {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.kind {
		margin-top: 22rpx;
	}

	.type-order {
		margin-left: 23rpx;
	}

	.price {
		color: #F45D1B;
		font-size: 24rpx;

		text {
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 800;

		}

	}

	.receive {
		width: 148rpx;
		height: 64rpx;
		background: #ED7200;
		border-radius: 32rpx;
		color: #fff;
		text-align: center;
		line-height: 64rpx;
		font-size: 26rpx;
	}
	.status-center {
		width: 460rpx;
		display: flex;
		align-items: center;
	}
</style>
